package o2o.web.actions.system;

import com.jinyou.utils.common.AjaxResult;
import com.jinyou.utils.common.ValidateUtil;
import o2o.config.annotation.LoginUser;
import o2o.dao.PO.user.UserInfo;
import o2o.service.sys.SystemMessagePushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @User: @Created by yangtk
 * @Date: @Date 2020/12/7 9:18
 * @Email: yangtongkuan@qq.com
 * @To change this template use File | Settings | File Templates.
 * @desc 系统消息推送
 */
@RestController
public class SysMessagePushController {

    @Autowired
    private SystemMessagePushService systemMessagePushService;

    // 发送推送消息
    @RequestMapping(value = "/admin/system/message/push", method = RequestMethod.POST)
    public String sysPushMessage(@LoginUser UserInfo user, Integer userType, String usernames, String city, String county, Long agentId, String title, String content) {
        if (ValidateUtil.isNull(title) || ValidateUtil.isNull(content)) {
            return AjaxResult.errorResult("消息名称或消息体不能为空");
        }
        systemMessagePushService.pushSystemMessage(user, userType, city, county, agentId, title, content);
        return AjaxResult.successResult();
    }


}
